#include "logger.h"

int LoggerFactory::open(){

  printf("%s","open");

  FILE *fp = fopen("./ebsx.log", "a+");
  /* unbuffered mode */
  setbuf(fp, NULL);

  _fp = fp;

  return 0;
}

BOOL LoggerFactory::init(){
  return StdoutLoggerFactory::init();
}

int LoggerFactory::close(){
  // FILE *fp = (FILE*)log4c_appender_get_udata(a_appender);
  // log4c_appender_set_udata(a_appender, NULL);
  return (_fp ? fclose(_fp) : 0);
}

int LoggerFactory::append(const log4c_logging_event_t *a_event){
  // FILE *fp = (FILE*)log4c_appender_get_udata(a_appender);

  
  return fprintf(_fp, "%s",
    // log4c_appender_get_name(_log4c_appender),
    // a_event->evt_category,
    // a_event->evt_priority,
    // a_event->evt_timestamp.tv_sec*1000000 + a_event->evt_timestamp.tv_usec,
    // a_event->evt_msg,
    // a_event->evt_loc->loc_file,
    // a_event->evt_loc->loc_line,
    a_event->evt_rendered_msg);
  

  // std::cout << a_event->evt_rendered_msg << std::endl;

  // return fprintf(fp, "%s", a_event->evt_rendered_msg);
  // return 0;
}

const char* LoggerFactory::getFilename(){
  return "111";
}


int main(){

  // C_LOG("%s","111");
  __log("default with %s","1");
  __cclog("EXP","default with %s","1");

  return 1;
}
